<template>
	<view class="team-info">
		<view class="list" style="width: 100%;">
			<team-info-item
				v-for="item in list"
				:key="item.id"
				:data="item">
			<template #right>
				<view class="right flex-grow-1" >
					
					<image style="width: 30rpx; height: 30rpx;margin-left: 70%;" :src="bianji" mode=""
						@click="bfEdit(item)"></image>
					<image style="width: 30rpx; height: 30rpx;margin-left: 10%;" :src="shanchu" mode=""
						@click="bfDel(item)"></image>
				</view>
			</template>
			</team-info-item>
		</view>
		
		<view class="bottom-add-btn">
			<u-button text="添加赛队" shape="circle" @click="add" color="linear-gradient(0deg, rgb(47, 117, 250) 0%, rgb(82, 142, 255) 100%)"></u-button>
		</view>
	</view>
</template>

<script>
	const venues = require("@/api/venues/venues.js");
	import { getCurrentPath } from '@/utils/util.js';
export default {
	data() {
		return {
			list: [],
			bianji: 'https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/7886aba3ece8aae3b489b1944b48572a4f092c41.png',
				shanchu: 'https://jiangsudiantuo2022.oss-cn-hangzhou.aliyuncs.com/img/fe85ef51643a187a6090a929b34e93738e12e365.png',
			
		}
	},
	onLoad() {
		this.getTeamList()
		
	},
	onShow() {
		this.getTeamList()
	},
	methods: {
		bfDel(item) {
			let that = this
			uni.showModal({
			    title: '删除',
			    content: '是否确定删除！',
			    success: function (res) {
			        if (res.confirm) {
			            console.log('用户点击确定');
						let params = {
							project_id: getApp().globalData.projectId,
							app_id: that.$https.weixinAppId,
							open_id: uni.getStorageSync("openid"),
							id: item.id,
						}
						venues.delTeam(params).then(res => {
							if (res.code == 1) {
								that.getTeamList()
							}
						})
			        } else if (res.cancel) {
			            console.log('用户点击取消');
			        }
			    }
			});
			
		},
		// 获取队伍列表
		async getTeamList() {
			let params = {
				open_id: uni.getStorageSync("openid"),
				project_id: getApp().globalData.projectId,
				app_id: this.$https.weixinAppId,
			}
			let res = await venues.getTeamList(params)
			if (res.code == 1) {
				this.list = res.data.result.itemArr
			}
		},
		bfEdit(item){
			console.log(item,'132')
			// uni.navigateTo({
			// 	url: '/page_venues/pages/member-info/add/add?id=' + item1.id
			// });
			uni.navigateTo({
			    url: '/page_venues/pages/team-info/add/add?item='+encodeURIComponent(JSON.stringify(item))
			});
		},
		add() {
			uni.navigateTo({
				url: '/page_venues/pages/team-info/add/add?type='+ 1
			});
		}
	}
}
</script>

<style lang="scss" scoped>
.team-info {
	min-height: 100vh;
	background-color: #f7f7f7;
	padding: 30rpx;
	padding-bottom: calc(150rpx + env(safe-area-inset-bottom));
}
</style>
